export default {
    props: {
        formDataAll: {
            type: Object,
            default: () => {
                return {}
            }
        },
        dialogType: {
            type: String,
            default: () => {
                return "add"
            }
        },
        show: {
            type: Boolean,
            default: () => false
        },
        disabled: {
            type: Boolean,
            default: () => false
        },
        item: {
            type: String,
            default: () => {
                return ""
            }
        },
        ROW: {
            type: Object,
            default: () => {
                return {}
            }
        },
        noBtn: {
            type: Boolean,
            default: () => {
                return false
            }
        },
    },
    methods: {
        addToSettingList(obj) {
            if (this.formDataAll.typeFunctionSettingList.length > 0) {
                let ids = this.formDataAll.typeFunctionSettingList.map(i => i.interfaceName);
                let inx = ids.indexOf(obj.interfaceName);

                if (inx === -1) {
                    this.formDataAll.typeFunctionSettingList.push(obj);
                } else {
                    this.formDataAll.typeFunctionSettingList[inx] = obj;
                }
            } else {
                this.formDataAll.typeFunctionSettingList.push(obj);
            }
        },
        removeItem(item, type) {
            if (this.formDataAll.typeFunctionSettingList.length > 0) {
                let ids = this.formDataAll.typeFunctionSettingList.map(i => i.interfaceName);
                let inx = ids.indexOf(item.interfaceName);
                this.formDataAll.typeFunctionSettingList.splice(inx, 1);

                if (type === "array") {
                    this.tableData = [];
                }

                if (type === "object") {
                    for (const key in this.formData) {
                        this.formData[key] = "";
                    }
                }
            }
        }
    }
}
